package com.wj.tool.utils;
 
import org.springframework.jdbc.core.JdbcTemplate;
import com.alibaba.druid.pool.DruidDataSource;
 
/**
 * 
 * @ClassName: DbOperationUtils
 * @date: 2018-12-25 下午8:21:30
 */
public class DbOperationUtils {
 
	/**
	 * 数据库连接需要的字符串
	 * */
	public static final String username = "developer";
	public static final String password = "dev@Cd2021084";
	public static final String jdbcUrl = "jdbc:mysql://192.168.10.93:3306/ft-greenhouse-2.2?useSSL=false&useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true&allowMultiQueries=true";
	public static final String driverName = "com.mysql.cj.jdbc.Driver";
 
	public static JdbcTemplate getJdbcTemplate() {
 
		// com.alibaba.druid.pool.DruidDataSource
		DruidDataSource dataSource = new DruidDataSource();
 
		// 设置数据源属性参数
		dataSource.setPassword(password);
		dataSource.setUrl(jdbcUrl);
		dataSource.setUsername(username);
		dataSource.setDriverClassName(driverName);
 
		// 获取spring的JdbcTemplate
		JdbcTemplate jdbcTemplate = new JdbcTemplate();
		// 设置数据源
		jdbcTemplate.setDataSource(dataSource);
 
		return jdbcTemplate;
	}
 
}